﻿#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
#endregion

namespace pigs
{
    /// <summary>
    /// The options screen is brought up over the top of the main menu
    /// screen, and gives the user a chance to configure the game
    /// in various hopefully useful ways.
    /// </summary>
    class AcheiveWinScreen : MenuScreen
    {
        Achievment a;
        ContentManager content;
        SpriteFont winFont;

        /// <summary>
        /// Constructor.
        /// </summary>
        public AcheiveWinScreen(ScreenManager screen, Achievment achiev)
            : base("Congratulations")
        {
            this.a = achiev;

            MenuEntry back = new MenuEntry("Back");
            back.Position = new Vector2(screen.GraphicsDevice.Viewport.Width / 2, 800);
            back.Selected += OnCancel;
            MenuEntries.Add(back);
        }

        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            this.winFont = content.Load<SpriteFont>("fonts/achievWinFont");
        }


        /// <summary>
        /// Draws the loading screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);

            base.Draw(gameTime);
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Darken down any other screens that were drawn beneath the popup.
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha / 3);

            Color color = Color.White * TransitionAlpha * TransitionAlpha;

            Vector2 position = new Vector2((viewportSize.X / 2) - (a.image.Width / 2), viewportSize.Y / 2 - a.image.Height / 2);
            a.position = position;
            // Draw the text.
            spriteBatch.Begin();
            a.Draw(spriteBatch, color, winFont, true);
            spriteBatch.End();
        }
    }
}
